home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------------
-
- Module name: PHIGS Debugger.
-
- Author: Steve Larkin.
-
- Function: This module contains the PHIGS Debugger.
-
- Dependencies:
-
- Internal function list:
-
- External function list:
-
- Modification history: (Version), (Date), (name), (Description).
-
- 1.0, 23rd August 1988, S. Larkin, First version.
-
- 2.0, 30th October 1991, G. Williams, Translated to C.
-
- ----------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <math.h>
- #include <phigs.h>
- #include "ptk.h"
-
- #ifdef SUN
- #define PICKDEV 2
- #define LOCDEV 1
- #endif
- #ifdef HP
- #define PICKDEV 2
- #define LOCDEV 1
- #endif
- #ifdef PEXSI
- #define LOCDEV 1
- #define PICKDEV 1
- #endif
-
- /* set a maximum limit on the number of elements to
- ** put in the structure content window. This is to enable
- ** the debugger to work with large structures ~3000 elements.
- ** Rebuilding the content diagram during scrolling etc. should be
- ** invisible to the user.
- */
- #define PTKSTCTLIMIT 100
-
- /*--------------------------------------------------------------------------*/
-
- /* debugger data structures */
-
- typedef enum
- {
- PTKEOK,
- PTKEBREAK,
- PTKESTRUCTEND,
- PTKEDEBUGEND,
- PTKEEXECUTE
- } ptketraversalstate;
-
- typedef enum
- {
- PTKEBREAKPT,
- PTKETRACEPT,
- PTKEWATCHPT,
- PTKENOOP
- } ptkeoperationtype;
-
- typedef struct ptksdebuginfo
- {
- Pint debugstid;
- Pint workingstid;
- Pint debugelptr;
- Pint workingelptr;
- Pint elemcount;
- Pelem_type eltype;
- } ptksdebuginfo;
-
- typedef struct ptksdebugstack
- {
- ptksdebuginfo debuginfo;
- struct ptksdebugstack *next;
- } ptksdebugstack;
-
- typedef struct ptksexeclist
- {
- Pint stid;
- Pint numelems;
- Pint_list bkpts;
- Pint_list tcpts;
- struct ptksexeclist *next;
- } ptksexeclist;
-
- static ptksdebugstack *debugstack = NULL;
- static ptksexeclist *stpoints = NULL;
-
- static ptksdebuginfo currentinfo;
- static Pint elembuffer;
- static Pint structbuffer;
- static Pint structwindow, topologywindow, contentwindow, terminalwindow;
- static Pint elementwindow;
- static ptkboolean elemposted = FALSE;
- static Pint dbgcount = 0;
- static Pint elemcontent, structcontent, currentcontent;
- static Pint contentlowlim, contentuplim;
- static Pint debugstackdepth = 0;
- static Pint debugwsid, debugrootstid;
- static Pint debugmenuid, windowmenuid, topologymenuid, contentmenuid;
- static Pint structmenuid, terminalmenuid, toptypemenuid;
- static Pint tslmenuid, tsl2menuid;
- static Pint rot3d1, rot3d2, rot2d1, rot2d2, rot1d;
- static Ppoint rot3d1pos, rot3d2pos, rot2d1pos, rot2d2pos, rot1dpos;
- static Pint topology, topologystid;
- static ptketraversalstate traversalstate;
- static Ppoint3 origin = {0.0, 0.0, 0.0};
- static Pint_list contentset;
- static Pfilter pickfilt;
- static Pint inclnames;
- static Plimit topview = {0.0, 1.0, 0.0, 1.0};
- static Pint curmenu = 0;
- static Pint curwindow = 0;
- static Pint lastcount, laststruct;
- static Pfloat devx, devy, devz;
- static Plimit echoarea;
-
- /* debugger attributes */
- static Pint menucolourind = 0;
- static Pint windowcolourind = 0;
- static Pint menutextcolourind = 1;
- static Pint bannercolourind = 1;
- static Pint bannertextcolourind = 0;
- static Pint menutextfont = 1;
- static Pint windowtextfont = 1;
- static Pint backgroundcolourind = 0;
- static Pint tlcolourind = 1;
- static Pint brcolourind = 1;
- static Pint arrowcolourind = 0;
- static Pint arrowedgecolourind = 1;
-
- /*--------------------------------------------------------------------------*/
-
- static void ptk_transformlimits(C(Plimit *) lims, C(Pmatrix) mat)
- PreANSI(Plimit *lims)
- PreANSI(Pmatrix mat)
- {
- Ppoint minbox, maxbox;
-
- minbox = ptk_point(lims->x_min, lims->y_min);
- maxbox = ptk_point(lims->x_max, lims->y_max);
- minbox = ptk_transform(mat, &minbox);
- maxbox = ptk_transform(mat, &maxbox);
- *lims = ptk_limit(minbox.x, maxbox.x, minbox.y, maxbox.y);
- } /* ptk_transformlimits */
-
- /*--------------------------------------------------------------------------*/
-
- static void ptk_scalelimits(C(Ppoint *) scale, C(Plimit *) lims)
- PreANSI(Ppoint *scale)
- PreANSI(Plimit *lims)
- {
- Ppoint minbox, maxbox;
- Ppoint shift, size;
- Pmatrix mat;
-
- minbox = ptk_point(lims->x_min, lims->y_min);
- maxbox = ptk_point(lims->x_max, lims->y_max);
- size = ptk_subv(&maxbox, &minbox);
- shift = ptk_point(minbox.x + (size.x / 2.0), minbox.y + (size.y / 2.0));
- shift = ptk_scalev(&shift, -1.0);
- ptk_shift(&shift, PTYPE_REPLACE, mat);
- ptk_scale(scale, PTYPE_POSTCONCAT, mat);
- shift = ptk_scalev(&shift, -1.0);
- ptk_shift(&shift, PTYPE_POSTCONCAT, mat);
- ptk_transformlimits(lims, mat);
- } /* ptk_scalelimits */
-
- /*--------------------------------------------------------------------------*/
-
- static void ptk_shiftlimits(C(Ppoint *) shift, C(Plimit *) lims)
- PreANSI(Ppoint *shift)
- PreANSI(Plimit *lims)
- {
- Ppoint minbox, maxbox;
- Pmatrix mat;
-
- minbox = ptk_point(lims->x_min, lims->y_min);
- maxbox = ptk_point(lims->x_max, lims->y_max);
- ptk_shift(shift, PTYPE_REPLACE, mat);
- minbox = ptk_transform(mat, &minbox);
- maxbox = ptk_transform(mat, &maxbox);
- *lims = ptk_limit(minbox.x, maxbox.x, minbox.y, maxbox.y);
- } /* ptk_shiftlimits */
-
- /*--------------------------------------------------------------------------*/
-
- static void ptk_stackdebug(C(ptksdebuginfo *) info)
- PreANSI(ptksdebuginfo *info)
- {
- ptksdebugstack *stackitem;
-
- stackitem = (ptksdebugstack *)malloc(sizeof(ptksdebugstack));
- stackitem->next = debugstack;
- debugstack = stackitem;
- stackitem->debuginfo = *info;
- debugstackdepth++;
- } /* ptk_stackdebug */
-
- /*--------------------------------------------------------------------------*/
-
- static void ptk_unstackdebug(C(ptksdebuginfo *) info)
- PreANSI(ptksdebuginfo *info)
- {
- ptksdebugstack *stackitem;
-
- if (debugstack != NULL)
- {
- *info = debugstack->debuginfo;
- stackitem = debugstack->next;
- free(debugstack);
- debugstack = stackitem;
- debugstackdepth--;
- }
- } /* ptk_unstackdebug */
-
- /*--------------------------------------------------------------------------*/
-
- static ptkboolean findstpoint(C(Pint) stid, C(ptksexeclist **) list)
- PreANSI(Pint stid)
- PreANSI(ptksexeclist **list)
- {
- *list = stpoints;
- while (*list != NULL)
- {
- if ((*list)->stid == stid)
- {
- return TRUE;
- }
- else
- *list = (*list)->next;
- }
- return FALSE;
- } /* findstpoint */
-
- /*--------------------------------------------------------------------------*/
-
- static ptkboolean findbreakpoint(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *ptr;
-
- if (findstpoint(stid, &ptr))
- if (inintlst(elemptr, &ptr->bkpts) != -1)
- return TRUE;
- return FALSE;
- } /* findbreakpoint */
-
- /*--------------------------------------------------------------------------*/
-
- static ptkboolean findtracepoint(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *ptr;
-
- if (findstpoint(stid, &ptr))
- if (inintlst(elemptr, &ptr->tcpts) != -1)
- return TRUE;
- return FALSE;
- } /* findtracepoint */
-
- /*--------------------------------------------------------------------------*/
-
- static deletebreakpt(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *ptr;
-
- if (findstpoint(stid, &ptr))
- {
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "struct$content-pts"));
- /* poffset_elem_ptr(1); */
- pset_elem_ptr_label(elemptr);
- ptk_delelem(2);
- }
- } /* deletebreakpt */
-
- /*--------------------------------------------------------------------------*/
-
- static deletetracept(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *ptr;
-
- if (findstpoint(stid, &ptr))
- {
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "struct$content-pts"));
- /* poffset_elem_ptr(1); */
- pset_elem_ptr_label(elemptr + ptr->numelems);
- ptk_delelem(2);
- }
- } /* deletetracept */
-
- /*--------------------------------------------------------------------------*/
-
- static drawbreakpt(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *ptr;
- Ppoint pts[5];
- Pint ind, base;
- Ppoint_list ptlist;
-
- if (findstpoint(stid, &ptr))
- {
- if ((ind = inintlst(elemptr, &ptr->bkpts)) != -1)
- {
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "struct$content-pts"));
- plabel(elemptr);
- if (contentlowlim <= 0)
- base = 0;
- else
- base = contentlowlim - 1;
- pts[0] = ptk_point(0.025, 1.0 - (0.1 *
- (ptr->bkpts.ints[ind] - base)) - 0.025);
- pts[1] = ptk_point(0.675, pts[0].y);
- pts[2] = ptk_point(0.675, pts[0].y - 0.05);
- pts[3] = ptk_point(0.025, pts[2].y);
- pts[4] = pts[0];
- ptlist.num_points = 5;
- ptlist.points = pts;
- ppolyline(&ptlist);
- }
- }
- } /* drawbreakpt */
-
- /*--------------------------------------------------------------------------*/
-
- static drawtracept(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *ptr;
- Ppoint pts[5];
- Pint ind, base;
- Ppoint_list ptlist;
-
- if (findstpoint(stid, &ptr))
- {
- if ((ind = inintlst(elemptr, &ptr->tcpts)) != -1)
- {
- plabel(elemptr + ptr->numelems);
- if (contentlowlim <= 0)
- base = 0;
- else
- base = contentlowlim - 1;
- pts[0] = ptk_point(0.025, 1.0 - (0.1 *
- (ptr->tcpts.ints[ind] - base)) - 0.025);
- pts[1] = ptk_point(0.675, pts[0].y);
- pts[2] = ptk_point(0.675, pts[0].y - 0.05);
- pts[3] = ptk_point(0.025, pts[2].y);
- pts[4] = pts[0];
- ptlist.num_points = 5;
- ptlist.points = pts;
- ppolyline(&ptlist);
- }
- }
- } /* drawtracept */
-
- /*--------------------------------------------------------------------------*/
-
- static drawbreakpts(C(Pint) stid)
- PreANSI(Pint stid)
- {
- ptksexeclist *ptr;
- Pint i, base;
- Ppoint pts[5];
- Ppoint_list ptlist;
-
- pset_linetype(PLINE_DASH);
- plabel(ptk_stringtoint("label", "struct$content-pts"));
- if (findstpoint(stid, &ptr))
- {
- for (i = 0; i < ptr->bkpts.num_ints; i++)
- {
- plabel(ptr->bkpts.ints[i]);
- if (contentlowlim <= 0)
- base = 0;
- else
- base = contentlowlim - 1;
- pts[0] = ptk_point(0.025, 1.0 - (0.1 *
- (ptr->bkpts.ints[i] - base)) - 0.025);
- pts[1] = ptk_point(0.675, pts[0].y);
- pts[2] = ptk_point(0.675, pts[0].y - 0.05);
- pts[3] = ptk_point(0.025, pts[2].y);
- pts[4] = pts[0];
- ptlist.num_points = 5;
- ptlist.points = pts;
- ppolyline(&ptlist);
- }
- }
- } /* drawbreakpts */
-
- /*--------------------------------------------------------------------------*/
-
- static drawtracepts(C(Pint) stid)
- PreANSI(Pint stid)
- {
- ptksexeclist *ptr;
- Pint i, base;
- Ppoint pts[5];
- Ppoint_list ptlist;
-
- pset_linetype(PLINE_DOT);
- if (findstpoint(stid, &ptr))
- {
- for (i = 0; i < ptr->tcpts.num_ints; i++)
- {
- plabel(ptr->bkpts.ints[i] + ptr->numelems);
- if (contentlowlim <= 0)
- base = 0;
- else
- base = contentlowlim - 1;
- pts[0] = ptk_point(0.025, 1.0 - (0.1 *
- (ptr->tcpts.ints[i] - base)) - 0.025);
- pts[1] = ptk_point(0.675, pts[0].y);
- pts[2] = ptk_point(0.675, pts[0].y - 0.05);
- pts[3] = ptk_point(0.025, pts[2].y);
- pts[4] = pts[0];
- ptlist.num_points = 5;
- ptlist.points = pts;
- ppolyline(&ptlist);
- }
- }
- } /* drawtracepts */
-
- /*--------------------------------------------------------------------------*/
-
- static Pint getcopystid(C(Pint) stid)
- PreANSI(Pint stid)
- /* map from real structure id to copy id */
- {
- char str[20];
-
- sprintf(str, "ptk$dbgst%d", stid);
- return ptk_stringtoint("structureid", str);
- } /* getcopystid */
-
- /*--------------------------------------------------------------------------*/
-
- static void copynetwork()
- {
- Pint i, j, tot, err, elptr, lstnum, stid, numelems;
- char str[20];
- Pint_list ids;
- ptkselcontent elcont;
- Pstore store;
- ptkboolean finished;
- Pelem_type eltype;
- Psearch_status srchstat;
-
- ptk_inqstructnetids(debugrootstid, 0, &ids, &tot);
- ids.ints = (Pint *)calloc(tot, sizeof(Pint));
- ptk_inqstructnetids(debugrootstid, tot, &ids, &tot);
- eltype = PELEM_EXEC_STRUCT;
- pcreate_store(&err, &store);
- for (i = 0; i < tot; i++)
- {
- sprintf(str, "ptk$dbgst%d", ids.ints[i]);
- stid = ptk_stringtoint("structureid", str);
- numelems = ptk_elemcount(ids.ints[i]);
- ptk_openstruct(stid);
- ptk_seteditmode(PEDIT_INSERT);
- pcopy_all_elems_struct(ids.ints[i]);
- ptk_unseteditmode();
- pset_elem_ptr(0);
- finished = FALSE;
- ptk_seteditmode(PEDIT_REPLACE);
- j = 0;
- while ((!finished) && (j <= numelems))
- {
- ptk_findelemtype(&eltype, 1, PDIR_FORWARD, &srchstat, &elptr, &lstnum);
- if (srchstat == PSEARCH_STATUS_SUCCESS)
- {
- pset_elem_ptr(elptr);
- ptk_inqcurelemtypesizecontent(store, &err, &elcont);
- pexec_struct(getcopystid(elcont.eldata->int_data));
- poffset_elem_ptr(1);
- j = elptr + 1;
- }
- else
- finished = TRUE;
- }
- ptk_unseteditmode();
- ptk_closestruct();
- }
- ptk_delstore(store);
- free(ids.ints);
- } /* copynetwork */
-
- /*--------------------------------------------------------------------------*/
-
- static Pint createnewstructid()
- /* working network */
- {
- char str[20];
-
- sprintf(str, "ptk$wkdbgst%d", dbgcount);
- dbgcount++;
- return ptk_stringtoint("structureid", str);
- } /* createnewstructid */
-
- /*--------------------------------------------------------------------------*/
-
- static void deletecopynetwork()
- /* delete the copy of the debugging structure network */
- {
- Pint i, tot;
- char str[20];
- Pint_list ids;
-
- /* delete copy network */
- sprintf(str, "ptk$dbgst%d", debugrootstid);
- /* Implementation dependent if problems
- ** with deleting structure networks e.g. DEC
- */
- #ifndef VMS
- pdel_struct_net(ptk_stringtoint("structureid", str), PFLAG_DEL);
- #endif
- ptk_inqstructnetids(debugrootstid, 0, &ids, &tot);
- ids.ints = (Pint *)calloc(tot, sizeof(Pint));
- ptk_inqstructnetids(debugrootstid, tot, &ids, &tot);
- for (i = 0; i < tot; i++)
- {
- sprintf(str, "ptk$dbgst%d", ids.ints[i]);
- /*
- #ifdef VMS
- pdel_struct(ptk_stringtoint("structureid", str));
- #endif
- */
- ptk_delstring("structureid", str);
- }
- free(ids.ints);
- }
-
- /*--------------------------------------------------------------------------*/
-
- static void clearstructid()
- /* Implementation dependent code.
- ** weird DEC PHIGS bug in DELETE STRUCTURE NETWORK,
- ** delete each structure in turn.
- */
- {
- Pint i, tot;
- char str[20];
- Pint_list ids;
-
- /* delete working network */
- sprintf(str, "ptk$wkdbgst%d", 0);
- #ifndef VMS
- pdel_struct_net(ptk_stringtoint("structureid", str), PFLAG_DEL);
- #endif
- for (i = 0; i < dbgcount; i++)
- {
- sprintf(str, "ptk$wkdbgst%d", i);
- /*
- #ifdef VMS
- pdel_struct(ptk_stringtoint("structureid", str));
- #endif
- */
- ptk_delstring("structureid", str);
- }
- } /* clearstructid */
-
- /*--------------------------------------------------------------------------*/
-
- static void setupdebugger(C(void))
- {
- elembuffer = ptk_stringtoint("structureid", "ptk$dbgelembuffer");
- elemcontent = ptk_stringtoint("structureid", "ptk$dbgelemcontent");
- structcontent = ptk_stringtoint("structureid", "ptk$dbgstructcontent");
- topology = ptk_stringtoint("topologyid", "ptk$dbgtopology");
- } /* setupdebugger */
-
- /*--------------------------------------------------------------------------*/
-
- static void initialisedebugger(C(Pint) stid)
- PreANSI(Pint stid)
- {
- Pint err;
- Pint_list stlist;
-
- traversalstate = PTKEOK;
- currentinfo.debugstid = stid;
- currentinfo.debugelptr = currentinfo.workingelptr = 1;
- currentinfo.elemcount = ptk_elemcount(stid);
-
- currentinfo.workingstid = createnewstructid();
- stlist.num_ints = 1;
- stlist.ints = &stid;
- ptk_resetcamera(structwindow);
- ptk_setcameraworld(structwindow, &stlist);
- ptk_posttowindow(structwindow, currentinfo.workingstid);
- ptk_createtopology(topology, stid, &err);
- ptk_posttowindow(topologywindow, topology);
- ptk_settopologyhighlightnode(topology, stid);
-
- /* inquire topology name for picking */
- ptk_inqtopologyname(topology, &inclnames, &err);
-
- contentset.num_ints = 1;
- contentset.ints = &inclnames;
- ptk_openstruct(structcontent);
- padd_names_set(&contentset);
- ptk_structcontent(debugwsid, stid, 0, PTKSTCTLIMIT, 1, 1, &err);
- currentcontent = stid;
- premove_names_set(&contentset);
- drawbreakpts(stid);
- drawtracepts(stid);
- ptk_closestruct();
- /* set current structure content limits */
- contentlowlim = 0;
- contentuplim = PTKSTCTLIMIT;
- ptk_posttowindow(contentwindow, structcontent);
- ptk_setcontentviewrange(contentwindow, 0, 10);
- if (currentinfo.elemcount > 0)
- {
- ptk_inqelemtype(stid, 1, &err, ¤tinfo.eltype);
- }
- else
- currentinfo.eltype = PELEM_NIL;
- ptk_openstruct(elembuffer);
- ptk_copyelem(stid, 1);
- ptk_closestruct();
-
- /* make topology and structure content pickable */
- ptk_inqtopologystructid(topology, &topologystid, &err);
- pickfilt.incl_set.num_ints = 1;
- pickfilt.incl_set.ints = &inclnames;
- pickfilt.excl_set.num_ints = 0;
- pset_pick_filter(debugwsid, PICKDEV, &pickfilt);
-
- ptk_posttowindow(elementwindow, elemcontent);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* initialisedebugger */
-
- /*--------------------------------------------------------------------------*/
-
- static void cleardebugger(C(void))
- {
- pempty_struct(elembuffer);
- pempty_struct(elemcontent);
- pempty_struct(structcontent);
-
- /* clear windows */
- ptk_unpostallfromwindow(structwindow);
- ptk_unpostallfromwindow(topologywindow);
- ptk_unpostallfromwindow(contentwindow);
- ptk_unpostallfromwindow(elementwindow);
-
- /* delete working network */
- clearstructid();
- dbgcount = 0;
-
- /* clear topology */
- ptk_deltopology(topology);
-
- /* finish traversal */
- /* if (traversalstate != PTKEDEBUGEND)
- ptk_tsltraversetoend(); */
-
- /* reset debugger variables */
- debugstack = NULL;
- debugstackdepth = 0;
- curmenu = 0;
- curwindow = 0;
- topview = ptk_limit(0.0, 1.0, 0.0, 1.0);
- } /* cleardebugger */
-
- /*--------------------------------------------------------------------------*/
-
- static void restarttraversal()
- {
- cleardebugger();
- initialisedebugger(debugrootstid);
- ptk_settslstart(getcopystid(debugrootstid), 0);
- ptk_tsltraversenext();
- } /* restarttraversal */
-
- /*--------------------------------------------------------------------------*/
-
- static void updateelembuffer(C(Pelem_type) eltype)
- PreANSI(Pelem_type eltype)
- {
- ptk_openstruct(elembuffer);
- ptk_seteditmode(PEDIT_REPLACE);
- if (eltype == PELEM_EXEC_STRUCT)
- ptk_copyelem(currentinfo.debugstid, currentinfo.debugelptr);
- else
- ptk_copyelem(getcopystid(currentinfo.debugstid), currentinfo.debugelptr);
- ptk_unseteditmode();
- ptk_closestruct();
- } /* updateelembuffer */
-
- /*--------------------------------------------------------------------------*/
-
- static void updatestructcontent(C(Pint) structid, C(Pint) elptr,
- C(Pint) range1, C(Pint) range2)
- PreANSI(Pint structid)
- PreANSI(Pint elptr)
- PreANSI(Pint range1)
- PreANSI(Pint range2)
- {
- Pint err;
-
- if (range1 < contentlowlim)
- {
- contentlowlim = range1 - PTKSTCTLIMIT / 2;
- contentuplim = range1 + PTKSTCTLIMIT / 2;
- }
- else
- if (range2 > contentuplim)
- {
- contentlowlim = range2 - (PTKSTCTLIMIT / 2);
- contentuplim = range2 + (PTKSTCTLIMIT / 2);
- }
- pempty_struct(structcontent);
- ptk_openstruct(structcontent);
- padd_names_set(&contentset);
- ptk_structcontent(debugwsid, structid, contentlowlim, contentuplim,
- elptr, 1, &err);
- currentcontent = structid;
- premove_names_set(&contentset);
- drawbreakpts(structid);
- drawtracepts(structid);
- ptk_closestruct();
- ptk_posttowindow(contentwindow, structcontent);
- ptk_setcontentviewrange(contentwindow, range1, range2);
- } /* updatestructcontent */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_next_elem(C(void))
- {
- Pint err, count, structid, elptr, lenstr;
- ptkselcontent elcont;
- char name[80];
- ptksdebuginfo temp;
- Pstore store;
-
- ptk_tsltraversenext();
- traversalstate = PTKEOK;
- if (findtracepoint(currentinfo.debugstid, currentinfo.debugelptr))
- {
- ptk_inttostring("structureid", currentinfo.debugstid, 80, name, &lenstr);
- if (lenstr == 0)
- sprintf(name, "%d\0", currentinfo.debugstid);
- ptk_printfterminal(terminalwindow,
- "tracepoint reached at structure %s, element %d.\n",
- name, currentinfo.debugelptr);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- if (currentinfo.eltype == PELEM_EXEC_STRUCT)
- {
- traversalstate = PTKEEXECUTE;
- temp = currentinfo;
- temp.debugelptr++;
- temp.workingelptr++;
- ptk_stackdebug(&temp);
- pcreate_store(&err, &store);
- ptk_inqelemtypesizecontent(elembuffer, 1, store, &err, &elcont);
- currentinfo.debugstid = elcont.eldata->int_data;
- ptk_delstore(store);
- currentinfo.debugelptr = 1;
- currentinfo.elemcount = ptk_elemcount(currentinfo.debugstid);
-
- if (currentinfo.elemcount > 0)
- {
- ptk_inqelemtype(currentinfo.debugstid, currentinfo.debugelptr,
- &err, ¤tinfo.eltype);
- updateelembuffer(currentinfo.eltype);
- }
- else
- currentinfo.eltype = PELEM_NIL;
-
- /* create new working structure */
- ptk_openstruct(currentinfo.workingstid);
- currentinfo.workingstid = createnewstructid();
- currentinfo.workingelptr = 1;
- pexec_struct(currentinfo.workingstid);
- ptk_closestruct();
- /* update topology */
- ptk_settopologyhighlightnode(topology, currentinfo.debugstid);
- /* update structure content */
- contentlowlim = 0;
- contentuplim = PTKSTCTLIMIT;
- updatestructcontent(currentinfo.debugstid, 1, 0, 10);
- }
- else
- {
- if (currentinfo.eltype != PELEM_NIL)
- {
- ptk_openstruct(currentinfo.workingstid);
- ptk_copyelem(elembuffer, 1);
- ptk_closestruct();
- }
-
- currentinfo.workingelptr++;
- currentinfo.debugelptr++;
-
- if (currentinfo.elemcount < currentinfo.debugelptr)
- {
- if ((currentinfo.elemcount == currentinfo.debugelptr - 1) ||
- (currentinfo.elemcount == currentinfo.debugelptr - 2))
- {
- lastcount = currentinfo.elemcount;
- laststruct = currentinfo.debugstid;
- }
- /* reached end of structure */
- traversalstate = PTKESTRUCTEND;
- if (debugstack == NULL)
- traversalstate = PTKEDEBUGEND;
- else
- {
- do
- {
- ptk_unstackdebug(¤tinfo);
- } while ((currentinfo.debugelptr > currentinfo.elemcount) &&
- (debugstack != NULL));
- if ((debugstack != NULL) ||
- (currentinfo.debugelptr < currentinfo.elemcount))
- {
- count = 10;
- elptr = currentinfo.debugelptr;
- structid = currentinfo.debugstid;
- }
- else
- {
- count = elptr = lastcount;
- structid = laststruct;
- }
- /* update topology */
- ptk_settopologyhighlightnode(topology, structid);
- /* update structure content */
- contentlowlim = count - (PTKSTCTLIMIT / 2);
- contentuplim = count + (PTKSTCTLIMIT / 2);
- updatestructcontent(structid, elptr, count - 10, count);
- }
- }
- else
- {
- if (currentcontent != currentinfo.debugstid)
- {
- contentlowlim = currentinfo.debugelptr - (PTKSTCTLIMIT / 2);
- contentuplim = currentinfo.debugelptr + (PTKSTCTLIMIT / 2);
- updatestructcontent(currentinfo.debugstid, currentinfo.debugelptr,
- currentinfo.debugelptr, currentinfo.debugelptr + 10);
- }
- else
- ptk_setstructcontentelemptr(structcontent, currentinfo.debugelptr);
- }
- if (currentinfo.elemcount >= currentinfo.debugelptr)
- {
- ptk_inqelemtype(currentinfo.debugstid, currentinfo.debugelptr,
- &err, ¤tinfo.eltype);
- updateelembuffer(currentinfo.eltype);
- }
- else
- currentinfo.eltype = PELEM_NIL;
- }
- if (findbreakpoint(currentinfo.debugstid, currentinfo.debugelptr))
- traversalstate = PTKEBREAK;
- } /* do_next_elem */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_step()
- {
- Pint startstid;
-
- if (traversalstate == PTKEDEBUGEND)
- restarttraversal();
- if (currentinfo.eltype == PELEM_EXEC_STRUCT)
- {
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- startstid = currentinfo.workingstid;
- do
- {
- if (currentinfo.eltype == PELEM_EXEC_STRUCT)
- {
- do_next_elem();
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- else
- do_next_elem();
- } while ((traversalstate != PTKEBREAK) &&
- (currentinfo.workingstid != startstid));
- }
- else
- do_next_elem();
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_step */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_stepreturn()
- {
- Pint startstid;
-
- if (traversalstate == PTKEDEBUGEND)
- restarttraversal();
- if (debugstack != NULL)
- {
- startstid = debugstack->debuginfo.debugstid;
- do
- {
- if (currentinfo.eltype == PELEM_EXEC_STRUCT)
- {
- do_next_elem();
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- else
- do_next_elem();
- } while ((traversalstate != PTKEBREAK) &&
- (currentinfo.debugstid != startstid));
- }
- else
- {
- /* at the root structure */
- do
- {
- if (currentinfo.eltype == PELEM_EXEC_STRUCT)
- {
- do_next_elem();
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- else
- do_next_elem();
- } while ((traversalstate == PTKEBREAK) && (traversalstate == PTKEDEBUGEND));
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_stepreturn */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_stepinto()
- {
- if (traversalstate == PTKEDEBUGEND)
- restarttraversal();
- if (currentinfo.eltype == PELEM_EXEC_STRUCT)
- do_next_elem();
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* stepinto */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_go()
- {
- Pint ws, devnum;
- Pin_class class;
-
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- if (traversalstate == PTKEDEBUGEND)
- restarttraversal();
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_NO_ECHO);
- do
- {
- if (currentinfo.eltype == PELEM_EXEC_STRUCT)
- {
- do_next_elem();
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- else
- do_next_elem();
- pawait_event(0.0, &ws, &class, &devnum);
- if ((ws == debugwsid) && (class == PIN_LOC))
- traversalstate = PTKEBREAK;
- } while ((traversalstate != PTKEBREAK) && (traversalstate != PTKEDEBUGEND));
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_go */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_examine(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- Pint err;
- ptkboolean graphics;
- Pint_list stlist;
-
- pempty_struct(elemcontent);
- ptk_openstruct(elemcontent);
- graphics = ptk_elemcontent(stid, elemptr, terminalwindow, &err);
- ptk_closestruct();
- if (graphics)
- {
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- stlist.num_ints = 1;
- stlist.ints = &elemcontent;
- ptk_resetcamera(elementwindow);
- ptk_setcameraworld(elementwindow, &stlist);
- if (!elemposted)
- {
- ptk_postwindow(elementwindow);
- elemposted = TRUE;
- }
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_examine */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_setbreakpoint(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *stptr, *newptr;
-
- if (!findstpoint(stid, &stptr))
- {
- newptr = (ptksexeclist *)malloc(sizeof(ptksexeclist));
- newptr->next = stpoints;
- stpoints = newptr;
- newptr->stid = stid;
- newptr->numelems = ptk_elemcount(stid);
- newptr->tcpts.num_ints = 0;
- newptr->tcpts.ints = (Pint *)calloc(50, sizeof(Pint));
- newptr->bkpts.num_ints = 1;
- newptr->bkpts.ints = (Pint *)calloc(50, sizeof(Pint));
- newptr->bkpts.ints[0] = elemptr;
- ptk_openstruct(structcontent);
- drawbreakpt(stid, elemptr);
- ptk_closestruct();
- }
- else
- if (inintlst(elemptr, &stptr->bkpts) == -1)
- {
- stptr->bkpts.ints[stptr->bkpts.num_ints++] = elemptr;
- ptk_openstruct(structcontent);
- drawbreakpt(stid, elemptr);
- ptk_closestruct();
- }
- } /* do_setbreakpoint */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_settracepoint(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *stptr, *newptr;
-
- if (!findstpoint(stid, &stptr))
- {
- newptr = (ptksexeclist *)malloc(sizeof(ptksexeclist));
- newptr->next = stpoints;
- stpoints = newptr;
- newptr->stid = stid;
- newptr->numelems = ptk_elemcount(stid);
- newptr->tcpts.num_ints = 1;
- newptr->tcpts.ints = (Pint *)calloc(50, sizeof(Pint));
- newptr->bkpts.num_ints = 0;
- newptr->bkpts.ints = (Pint *)calloc(50, sizeof(Pint));
- newptr->tcpts.ints[0] = elemptr;
- ptk_openstruct(structcontent);
- drawtracept(stid, elemptr);
- ptk_closestruct();
- }
- else
- if (inintlst(elemptr, &stptr->tcpts) == -1)
- {
- stptr->tcpts.ints[stptr->tcpts.num_ints++] = elemptr;
- ptk_openstruct(structcontent);
- drawtracept(stid, elemptr);
- ptk_closestruct();
- }
- } /* do_settracepoint */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_cancelbreakpoint(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *stptr;
- Pint i, ind;
-
- if (findstpoint(stid, &stptr))
- {
- if ((ind = inintlst(elemptr, &stptr->bkpts)) != -1)
- {
- for (i = ind; i < stptr->bkpts.num_ints; i++)
- stptr->bkpts.ints[i] = stptr->bkpts.ints[i + 1];
- stptr->bkpts.num_ints--;
- ptk_openstruct(structcontent);
- deletebreakpt(stid, elemptr);
- ptk_closestruct();
- }
- }
- } /* do_cancelbreakpoint */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_canceltracepoint(C(Pint) stid, C(Pint) elemptr)
- PreANSI(Pint stid)
- PreANSI(Pint elemptr)
- {
- ptksexeclist *stptr;
- Pint i, ind;
-
- if (findstpoint(stid, &stptr))
- {
- if ((ind = inintlst(elemptr, &stptr->tcpts)) != -1)
- {
- for (i = ind; i < stptr->tcpts.num_ints; i++)
- stptr->tcpts.ints[i] = stptr->tcpts.ints[i + 1];
- stptr->tcpts.num_ints--;
- ptk_openstruct(structcontent);
- deletetracept(stid, elemptr);
- ptk_closestruct();
- }
- }
- } /* do_canceltracepoint */
-
- /*--------------------------------------------------------------------------*/
-
- static void makemenus(C(void))
- {
- Pint err;
- Ppoint topleft;
- Ppoint box, size;
-
- /* debugger menu */
- debugmenuid = ptk_stringtoint("menuid", "ptk$debugmenu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(debugmenuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, debugmenuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(debugmenuid, "go", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "step", 2, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "step in", 3, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "examine", 4, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "deposit", 5, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "phinter", 6, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "TSL", 7, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "restart", 8, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "refresh", 9, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(debugmenuid, "exit", 10, PEDIT_INSERT, &err);
-
- /* window menu */
- windowmenuid = ptk_stringtoint("menuid", "ptk$windowmenu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(windowmenuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, windowmenuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(windowmenuid, "close", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(windowmenuid, "move", 2, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(windowmenuid, "resize", 3, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(windowmenuid, "front", 4, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(windowmenuid, "back", 5, PEDIT_INSERT, &err);
-
- /* topology menu */
- topologymenuid = ptk_stringtoint("menuid", "ptk$topologymenu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(topologymenuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, topologymenuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(topologymenuid, "type", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(topologymenuid, "view", 2, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(topologymenuid, "tidy node", 3, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(topologymenuid, "tidy group", 4, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(topologymenuid, "store", 5, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(topologymenuid, "restore", 6, PEDIT_INSERT, &err);
-
- /* content menu */
- contentmenuid = ptk_stringtoint("menuid", "ptk$contentmenu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(contentmenuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, contentmenuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(contentmenuid, "set break", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(contentmenuid, "set trace", 2, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(contentmenuid, "cancel brk", 3, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(contentmenuid, "cancel trc", 4, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(contentmenuid, "scroll", 5, PEDIT_INSERT, &err);
-
- /* structure menu */
- structmenuid = ptk_stringtoint("menuid", "ptk$structmenu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(structmenuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, structmenuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(structmenuid, "camera", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(structmenuid, "reset", 2, PEDIT_INSERT, &err);
-
- /* terminal menu */
- terminalmenuid = ptk_stringtoint("menuid", "ptk$terminalmenu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(terminalmenuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, terminalmenuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(terminalmenuid, "scroll", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(terminalmenuid, "clear", 2, PEDIT_INSERT, &err);
-
- /* topology type menu */
- toptypemenuid = ptk_stringtoint("menuid", "ptk$toptypemenu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(toptypemenuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, toptypemenuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(toptypemenuid, "box", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(toptypemenuid, "struct", 2, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(toptypemenuid, "structnet", 3, PEDIT_INSERT, &err);
-
- /* TSL menu */
- tslmenuid = ptk_stringtoint("menuid", "ptk$tslmenu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(tslmenuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, tslmenuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(tslmenuid, "line", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tslmenuid, "marker", 2, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tslmenuid, "interior", 3, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tslmenuid, "edge", 4, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tslmenuid, "text", 5, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tslmenuid, "annotext", 6, PEDIT_INSERT, &err);
-
- /* TSL2 menu */
- tsl2menuid = ptk_stringtoint("menuid", "ptk$tsl2menu");
- box = ptk_point(0.1, 0.05);
- topleft = ptk_point(0.0, 1.0);
- ptk_createboxmenu(tsl2menuid, &topleft, &box);
- ptk_setboxmenuattrs(debugwsid, tsl2menuid, PPATH_DOWN, menutextfont,
- menutextcolourind, menucolourind,
- bannercolourind, tlcolourind, brcolourind,
- menutextcolourind, menucolourind, menucolourind);
-
- ptk_createtextmenuitem(tsl2menuid, "char", 1, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tsl2menuid, "ctm", 2, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tsl2menuid, "nameset", 3, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tsl2menuid, "ids", 4, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tsl2menuid, "asf", 5, PEDIT_INSERT, &err);
- ptk_createtextmenuitem(tsl2menuid, "bbox", 6, PEDIT_INSERT, &err);
-
- /* rotators */
- rot3d1 = ptk_stringtoint("menuid", "ptk$rotator3d1");
- rot3d2 = ptk_stringtoint("menuid", "ptk$rotator3d2");
- rot2d1 = ptk_stringtoint("menuid", "ptk$rotator2d1");
- rot2d2 = ptk_stringtoint("menuid", "ptk$rotator2d2");
- rot1d = ptk_stringtoint("menuid", "ptk$rotator1d");
- rot3d1pos = ptk_point(0.15, 0.88);
- rot3d2pos = ptk_point(0.15, 0.66);
- rot2d1pos = ptk_point(0.1, 0.88);
- rot2d2pos = ptk_point(0.1, 0.66);
- rot1dpos = ptk_point(0.1, 0.66);
- size = ptk_point(0.3, 0.2);
- ptk_createrotator(debugwsid, rot3d1, PTKETHREED, &size, "rotator",
- 0.02);
- ptk_setrotatorattrs(debugwsid, rot3d1, windowtextfont,
- bannertextcolourind, arrowcolourind,
- arrowedgecolourind,
- windowcolourind, bannercolourind,
- bannercolourind, tlcolourind, brcolourind);
- ptk_createrotator(debugwsid, rot3d2, PTKETHREED, &size, "rotator",
- 0.02);
- ptk_setrotatorattrs(debugwsid, rot3d2, windowtextfont,
- bannertextcolourind, arrowcolourind,
- arrowedgecolourind,
- windowcolourind, bannercolourind,
- bannercolourind, tlcolourind, brcolourind);
- size = ptk_point(0.2, 0.2);
- ptk_createrotator(debugwsid, rot2d1, PTKETWOD, &size, "rotator",
- 0.02);
- ptk_setrotatorattrs(debugwsid, rot2d1, windowtextfont,
- bannertextcolourind, arrowcolourind,
- arrowedgecolourind,
- windowcolourind, bannercolourind,
- bannercolourind, tlcolourind, brcolourind);
- ptk_createrotator(debugwsid, rot2d2, PTKETWOD, &size, "rotator",
- 0.02);
- ptk_setrotatorattrs(debugwsid, rot2d2, windowtextfont,
- bannertextcolourind, arrowcolourind,
- arrowedgecolourind,
- windowcolourind, bannercolourind,
- bannercolourind, tlcolourind, brcolourind);
- ptk_createrotator(debugwsid, rot1d, PTKEONED, &size, "rotator",
- 0.02);
- ptk_setrotatorattrs(debugwsid, rot1d, windowtextfont,
- bannertextcolourind, arrowcolourind,
- arrowedgecolourind,
- windowcolourind, bannercolourind,
- bannercolourind, tlcolourind, brcolourind);
- ptk_setmenuposition(rot3d1, &rot3d1pos);
- ptk_setmenuposition(rot3d2, &rot3d2pos);
- ptk_setmenuposition(rot2d1, &rot2d1pos);
- ptk_setmenuposition(rot2d2, &rot2d2pos);
- ptk_setmenuposition(rot1d, &rot1dpos);
- } /* makemenus */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_moverotator(C(Pint) menuid)
- PreANSI(Pint menuid)
- {
- Ppoint *pos, inpos;
- Pint initview, view_index, tot, err;
- Pin_status status;
- Plimit echo;
- Ploc_data locrec;
- char title[30];
-
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_UQUM);
- ptk_inqrotatortitle(menuid, 30, title, &tot, &err);
- ptk_setrotatortitle(menuid, "MOVE");
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- if (menuid == rot3d1)
- pos = &rot3d1pos;
- else
- if (menuid == rot3d2)
- pos = &rot3d2pos;
- else
- if (menuid == rot2d1)
- pos = &rot2d1pos;
- else
- if (menuid == rot2d2)
- pos = &rot2d2pos;
- else
- if (menuid == rot1d)
- pos = &rot1dpos;
- initview = 0;
- echo = ptk_limit(0.0, devx, 0.0, devy);
- /* Implementation dependent - locator device data record */
- #ifdef HP
- locrec.pets.pet_r1.loc_colr_ind = 1;
- #endif
- pinit_loc(debugwsid, LOCDEV, initview, pos, 1, &echo, &locrec);
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- preq_loc(debugwsid, LOCDEV, &status, &view_index, &inpos);
- if (status == PIN_STATUS_OK)
- {
- *pos = inpos;
- ptk_setmenuposition(menuid, pos);
- }
- ptk_setrotatortitle(menuid, title);
- } /* do_moverotator */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_pickelem(C(Pint *) stid, C(Pint *) elemptr)
- PreANSI(Pint *stid)
- PreANSI(Pint *elemptr)
- {
- Ppick_path pick;
- Pin_status status;
- Ppick_path_elem pathel[10];
- Pfilter contentfilt;
-
- contentfilt.incl_set = contentset;
- contentfilt.excl_set = pickfilt.excl_set;
- *stid = currentcontent;
- pset_pick_filter(debugwsid, PICKDEV, &contentfilt);
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- pset_pick_mode(debugwsid, PICKDEV, POP_REQ, PSWITCH_ECHO);
- pick.path_list = pathel;
- preq_pick(debugwsid, PICKDEV, 10, &status, &pick);
- if (status == PIN_STATUS_OK)
- *elemptr = pick.path_list[1].pick_id;
- else
- *elemptr = -1;
- } /* do_pickelem */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_scrollterminal()
- {
- ptkboolean quit;
- Pint ws, devnum;
- Pin_class class;
- Ppoint position;
- Pint view_index;
- ptksgeneralinput geninput;
- ptksmenuoutput menuoutput;
- Ploc_data locrec;
- Ptext_path direction;
- Pint numlines, maxlines, maxcolumns, txfont, txcolour, err;
-
- ptk_setrotatortitle(rot1d, "scroll terminal");
- ptk_postmenu(debugwsid, rot1d);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- quit = FALSE;
- ptk_inqterminaldata(terminalwindow, &maxlines, &maxcolumns, &txfont,
- &txcolour, &err);
- do
- {
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- pawait_event(0.0, &ws, &class, &devnum);
- if ((class == PIN_LOC) && (ws == debugwsid))
- {
- pget_loc(&view_index, &position);
- geninput.inputclass = PIN_LOC;
- geninput.ptkugeninput.locpoint = position;
- if (ptk_scanmenus(debugwsid, &geninput, &menuoutput))
- {
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- if (menuoutput.menuid == rot1d)
- {
- if (menuoutput.itemnum == 0)
- do_moverotator(rot1d);
- else
- {
- switch (menuoutput.itemnum)
- {
- case 1:
- direction = PPATH_DOWN;
- numlines = (Pint)(menuoutput.value.y * (Pfloat)maxlines);
- break;
-
- case 2:
- direction = PPATH_UP;
- numlines = (Pint)((1.0 - menuoutput.value.y) *
- (Pfloat)maxlines);
- break;
- }
- ptk_scrollterminal(terminalwindow, direction, numlines);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- }
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- }
- else
- {
- quit = TRUE;
- }
- }
- } while (!quit);
- ptk_unpostmenu(debugwsid, rot1d);
- } /* do_scrollterminal */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_scrollcontent()
- {
- ptkboolean quit;
- Pint ws, devnum;
- Pin_class class;
- Ppoint position;
- Pint view_index, eptr;
- ptksgeneralinput geninput;
- ptksmenuoutput menuoutput;
- Ploc_data locrec;
- Ptext_path direction;
- Pint numlines, range1, range2, maxrange2, err, scrollfactor;
-
- ptk_setrotatortitle(rot1d, "scroll content");
- ptk_postmenu(debugwsid, rot1d);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- quit = FALSE;
- maxrange2 = ptk_elemcount(currentcontent);
- ptk_inqcontentviewrange(contentwindow, &range1, &range2, &err);
- scrollfactor = range2 - range1;
- if (scrollfactor < 10)
- scrollfactor = 10;
- do
- {
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- pawait_event(0.0, &ws, &class, &devnum);
- if ((class == PIN_LOC) && (ws == debugwsid))
- {
- pget_loc(&view_index, &position);
- geninput.inputclass = PIN_LOC;
- geninput.ptkugeninput.locpoint = position;
- if (ptk_scanmenus(debugwsid, &geninput, &menuoutput))
- {
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- if (menuoutput.menuid == rot1d)
- {
- if (menuoutput.itemnum == 0)
- do_moverotator(rot1d);
- else
- {
- switch (menuoutput.itemnum)
- {
- case 1:
- numlines = (Pint)(menuoutput.value.y * (Pfloat)scrollfactor);
- if (range1 - numlines >= 0)
- {
- range1 -= numlines;
- range2 -= numlines;
- }
- else
- {
- range1 = 0;
- range2 = scrollfactor;
- }
- break;
-
- case 2:
- numlines = (Pint)((1.0 - menuoutput.value.y) *
- (Pfloat)scrollfactor);
- if (range2 + numlines <= maxrange2)
- {
- range1 += numlines;
- range2 += numlines;
- }
- else
- {
- range1 = maxrange2 - scrollfactor;
- range2 = maxrange2;
- }
- break;
- }
- if ((range1 - scrollfactor) < contentlowlim)
- {
- contentlowlim = range1 - (PTKSTCTLIMIT / 2);
- contentuplim = range1 + (PTKSTCTLIMIT / 2);
- eptr = -1;
- if (currentcontent == currentinfo.debugstid)
- eptr = currentinfo.debugelptr;
- updatestructcontent(currentcontent, eptr, range1, range2);
- }
- else
- if ((range2 + scrollfactor) > contentuplim)
- {
- contentlowlim = range2 - (PTKSTCTLIMIT / 2);
- contentuplim = range2 + (PTKSTCTLIMIT / 2);
- eptr = -1;
- if (currentcontent == currentinfo.debugstid)
- eptr = currentinfo.debugelptr;
- updatestructcontent(currentcontent, eptr, range1, range2);
- }
- else
- ptk_setcontentviewrange(contentwindow, range1, range2);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- }
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- }
- else
- {
- quit = TRUE;
- }
- }
- } while (!quit);
- ptk_unpostmenu(debugwsid, rot1d);
- } /* do_scrollcontent */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_zoompantopology(C(ptksmenuoutput *) menuout, C(Plimit *) window)
- PreANSI(ptksmenuoutput *menuout)
- PreANSI(Plimit *window)
- {
- Ppoint shift, scale;
- Pfloat movefactor;
-
- movefactor = (topview.x_max - topview.x_min) / 2.0;
- switch (menuout->itemnum)
- {
- case 1: /* decrease y */
- shift = ptk_point(0.0, (menuout->value.y * movefactor));
- ptk_shiftlimits(&shift, window);
- break;
-
- case 2: /* increase y */
- shift = ptk_point(0.0, -((1.0 - menuout->value.y) * movefactor));
- ptk_shiftlimits(&shift, window);
- break;
-
- case 3: /* increase x */
- shift = ptk_point(-((1.0 - menuout->value.x) * movefactor), 0.0);
- ptk_shiftlimits(&shift, window);
- break;
-
- case 4: /* decrease x */
- shift = ptk_point((menuout->value.x * movefactor), 0.0);
- ptk_shiftlimits(&shift, window);
- break;
-
- case 5: /* decrease x and y */
- scale = ptk_point(1.0 - (menuout->value.y * 0.1),
- 1.0 - (menuout->value.y * 0.1));
- ptk_scalelimits(&scale, window);
- break;
-
- case 6: /* increase x and y */
- scale = ptk_point(1.0 + (menuout->value.y * 0.1),
- 1.0 + (menuout->value.y * 0.1));
- ptk_scalelimits(&scale, window);
- break;
- }
- } /* do_zoompantopology */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_topologyview()
- {
- ptkboolean quit;
- Pint ws, devnum;
- Pin_class class;
- Ppoint position;
- Pint view_index;
- ptksgeneralinput geninput;
- ptksmenuoutput menuoutput;
- Ploc_data locrec;
-
- ptk_setrotatortitle(rot3d1, "zoom + pan");
- ptk_postmenu(debugwsid, rot3d1);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- quit = FALSE;
- do
- {
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- pawait_event(0.0, &ws, &class, &devnum);
- if ((class == PIN_LOC) && (ws == debugwsid))
- {
- pget_loc(&view_index, &position);
- geninput.inputclass = PIN_LOC;
- geninput.ptkugeninput.locpoint = position;
- if (ptk_scanmenus(debugwsid, &geninput, &menuoutput))
- {
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- if (menuoutput.menuid == rot3d1)
- {
- if (menuoutput.itemnum == 0)
- do_moverotator(rot3d1);
- else
- {
- do_zoompantopology(&menuoutput, &topview);
- ptk_settopologyviewarea(topologywindow, &topview);
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- }
- else
- {
- quit = TRUE;
- }
- }
- } while (!quit);
- ptk_unpostmenu(debugwsid, rot3d1);
- } /* do_topologyview */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_spincamera(C(Pint) windid, C(ptksmenuoutput *) menuout)
- PreANSI(Pint windid)
- PreANSI(ptksmenuoutput *menuout)
- {
- Pfloat angle;
-
- switch (menuout->itemnum)
- {
- case 1:
- angle = menuout->value.y * 10.0;
- ptk_rotatepositionxaxis(windid, angle);
- break;
-
- case 2:
- angle = (1.0 - menuout->value.y) * 10.0;
- ptk_rotatepositionxaxis(windid, -angle);
- break;
-
- case 3:
- angle = (1.0 - menuout->value.x) * 10.0;
- ptk_rotatepositionyaxis(windid, angle);
- break;
-
- case 4:
- angle = menuout->value.x * 10.0;
- ptk_rotatepositionyaxis(windid, -angle);
- break;
-
- case 5:
- angle = menuout->value.y * 10.0;
- ptk_rotatecameraupvector(windid, angle);
- break;
-
- case 6:
- angle = menuout->value.y * 10.0;
- ptk_rotatecameraupvector(windid, -angle);
- break;
- }
- } /* do_spincamera */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_zoompancamera(C(Pint) windid, C(ptksmenuoutput *) menuout)
- PreANSI(Pint windid)
- PreANSI(ptksmenuoutput *menuout)
- {
- Pfloat zoomfactor, xsize, ysize;
- Ppoint3 shift;
- Plimit3 limits;
- Pint err;
-
- ptk_inqcameralimits(windid, &limits, &err);
- xsize = limits.x_max - limits.x_min;
- ysize = limits.y_max - limits.y_min;
- xsize /= 2.0;
- ysize /= 2.0;
- switch (menuout->itemnum)
- {
- case 1:
- shift = ptk_point3(0.0, menuout->value.y * ysize, 0.0);
- ptk_shiftcamera(windid, &shift);
- break;
-
- case 2:
- shift = ptk_point3(0.0, -(1.0 - menuout->value.y) * ysize, 0.0);
- ptk_shiftcamera(windid, &shift);
- break;
-
- case 3:
- shift = ptk_point3(-(1.0 - menuout->value.x) * xsize, 0.0, 0.0);
- ptk_shiftcamera(windid, &shift);
- break;
-
- case 4:
- shift = ptk_point3(menuout->value.x * xsize, 0.0, 0.0);
- ptk_shiftcamera(windid, &shift);
- break;
-
- case 5:
- zoomfactor = menuout->value.y * 0.1;
- ptk_scaleviewwindow(windid, 1.0 - zoomfactor);
- break;
-
- case 6:
- zoomfactor = menuout->value.y * 0.1;
- ptk_scaleviewwindow(windid, 1.0 + zoomfactor);
- break;
- }
- } /* do_zoompancamera */
-
- /*--------------------------------------------------------------------------*/
-
- static void camerainterface(C(Pint) windid)
- PreANSI(Pint windid)
- {
- ptkboolean cameraquit;
- Pint ws, devnum;
- Pin_class class;
- Ppoint position;
- Pint view_index;
- ptksgeneralinput geninput;
- ptksmenuoutput menuoutput;
- Ploc_data locrec;
-
- ptk_setrotatortitle(rot3d1, "rotate");
- ptk_setrotatortitle(rot3d2, "zoom + pan");
- ptk_postmenu(debugwsid, rot3d1);
- ptk_postmenu(debugwsid, rot3d2);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- cameraquit = FALSE;
- do
- {
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- pawait_event(0.0, &ws, &class, &devnum);
- if ((class == PIN_LOC) && (ws == debugwsid))
- {
- pget_loc(&view_index, &position);
- geninput.inputclass = PIN_LOC;
- geninput.ptkugeninput.locpoint = position;
- if (ptk_scanmenus(debugwsid, &geninput, &menuoutput))
- {
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- if (menuoutput.menuid == rot3d1)
- {
- if (menuoutput.itemnum == 0)
- do_moverotator(rot3d1);
- else
- do_spincamera(windid, &menuoutput);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- else
- if (menuoutput.menuid == rot3d2)
- {
- if (menuoutput.itemnum == 0)
- do_moverotator(rot3d2);
- else
- do_zoompancamera(windid, &menuoutput);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- }
- else
- {
- cameraquit = TRUE;
- }
- }
- } while (!cameraquit);
- ptk_unpostmenu(debugwsid, rot3d1);
- ptk_unpostmenu(debugwsid, rot3d2);
- } /* camerainterface */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_debugmenu(C(Pint) menuitem, C(Ppoint *) pos)
- PreANSI(Pint menuitem)
- PreANSI(Ppoint *pos)
- {
- Ppoint pos2;
- Pint stid, elemptr, err;
- Pelem_type eltype;
- Pint_list stlist;
-
- switch (menuitem)
- {
- case 1: /* go */
- ptk_unpostallmenu(debugwsid);
- curmenu = 0;
- do_go();
- break;
-
- case 2: /* step */
- do_step();
- break;
-
- case 3: /* step into */
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- do_stepinto();
- break;
-
- case 4: /* examine */
- do_examine(elembuffer, 1);
- break;
-
- case 5: /* deposit */
- if (traversalstate != PTKEDEBUGEND)
- {
- ptk_openstruct(getcopystid(currentinfo.debugstid));
- pset_elem_ptr(currentinfo.workingelptr);
- ptk_inqcurelemtype(&err, &eltype);
- if (eltype != PELEM_EXEC_STRUCT)
- {
- ptk_seteditmode(PEDIT_REPLACE);
- ptk_readelem(debugwsid, &echoarea, eltype);
-
- ptk_closestruct();
- ptk_openstruct(elembuffer);
- ptk_copyelem(getcopystid(currentinfo.debugstid),
- currentinfo.workingelptr);
- ptk_unseteditmode();
- }
- ptk_closestruct();
- }
- else
- ptk_writelnterminal(terminalwindow, "At end of structure network.");
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- break;
-
- case 6: /* phinter */
- ptk_callphinter();
- break;
-
- case 7: /* tsl menu */
- ptk_setmenuposition(tslmenuid, pos);
- ptk_postmenu(debugwsid, tslmenuid);
- pos2 = *pos;
- pos2.x += 0.1;
- ptk_setmenuposition(tsl2menuid, &pos2);
- ptk_postmenu(debugwsid, tsl2menuid);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- break;
-
- case 8: /* restart */
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- restarttraversal();
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- break;
-
- case 9: /* refresh */
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- predraw_all_structs(debugwsid, PFLAG_ALWAYS);
- break;
- }
- } /* do_debugmenu */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_windowmenu(C(Pint) menuitem, C(ptkswindowoutput *) windoutput)
- PreANSI(Pint menuitem)
- PreANSI(ptkswindowoutput *windoutput)
- {
- ptkboolean closed;
- Plimit echo;
- Ploc_data locrec;
- Ppoint initpt, position;
- Pint initview, view_index;
- Pint err;
- Pin_status status;
-
- if (windoutput->windowarea == PTKEWINDOWICON)
- closed = TRUE;
- else
- closed = FALSE;
- echo = ptk_limit(0.0, devx, 0.0, devy);
- switch (menuitem)
- {
- case 1: /* open/close */
- if (closed)
- ptk_openwindow(windoutput->windowid);
- else
- ptk_closewindow(windoutput->windowid);
- break;
-
- case 2: /* move */
- {
- initview = 0;
- if (closed)
- ptk_inqiconposition(windoutput->windowid, &initpt, &err);
- else
- ptk_inqwindowposition(windoutput->windowid, &initpt, &err);
- /* Implementation dependent - locator device data record */
- #ifdef HP
- locrec.pets.pet_r1.loc_colr_ind = 1;
- #endif
- pinit_loc(debugwsid, LOCDEV, initview, &initpt, 1, &echo, &locrec);
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- preq_loc(debugwsid, LOCDEV, &status, &view_index, &position);
- if (status == PIN_STATUS_OK)
- if (closed)
- ptk_seticonposition(windoutput->windowid, &position);
- else
- {
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- ptk_setwindowposition(windoutput->windowid, &position);
- }
- }
- break;
-
- case 3: /* resize */
- {
- Pfloat width, height;
- Ppoint size;
-
- initview = 0;
- if (closed)
- ptk_inqiconposition(windoutput->windowid, &initpt, &err);
- else
- ptk_inqwindowposition(windoutput->windowid, &initpt, &err);
-
- /* implementation dependent code
- ** to produce rubber banding rectangle (locator pet)
- */
- #ifdef SUN
- locrec.pets.pet_u5.line_bundle.type = PLINE_SOLID;
- locrec.pets.pet_u5.line_bundle.width = 1.0;
- locrec.pets.pet_u5.line_bundle.colr_ind = 1;
- pinit_loc(debugwsid, LOCDEV, initview, &initpt, -5, &echo, &locrec);
- #endif
- #ifdef HP
- locrec.pets.pet_r5.line_fill_ctrl_flag = PFLAG_LINE;
- locrec.pets.pet_r5.attrs.line_attrs.type_asf = PASF_INDIV;
- locrec.pets.pet_r5.attrs.line_attrs.width_asf = PASF_INDIV;
- locrec.pets.pet_r5.attrs.line_attrs.colr_ind_asf = PASF_INDIV;
- locrec.pets.pet_r5.attrs.line_attrs.bundle.type = PLINE_SOLID;
- locrec.pets.pet_r5.attrs.line_attrs.bundle.width = 1.0;
- locrec.pets.pet_r5.attrs.line_attrs.bundle.colr_ind = 1;
- pinit_loc(debugwsid, LOCDEV, initview, &initpt, 5, &echo, &locrec);
- #endif
- #ifdef PEXSI
- pinit_loc(debugwsid, LOCDEV, initview, &initpt, 1, &echo, &locrec);
- #endif
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- preq_loc(debugwsid, LOCDEV, &status, &view_index, &position);
- if (status == PIN_STATUS_OK)
- {
- width = PTKMAX(initpt.x, position.x) - PTKMIN(initpt.x, position.x);
- height = PTKMAX(initpt.y, position.y) -
- PTKMIN(initpt.y, position.y);
- width *= 2.0;
- height *= 2.0;
- size = ptk_point(width, height);
- if (closed)
- ptk_seticonsize(windoutput->windowid, &size);
- else
- {
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- ptk_setwindowsize(windoutput->windowid, &size);
- }
- }
- /* Implementation dependent - locator device data record */
- #ifdef HP
- locrec.pets.pet_r1.loc_colr_ind = 1;
- #endif
- pinit_loc(debugwsid, LOCDEV, initview, &initpt, 1, &echo, &locrec);
- }
- break;
-
- case 4: /* front */
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- ptk_frontwindow(windoutput->windowid);
- break;
-
- case 5: /* back */
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- ptk_backwindow(windoutput->windowid);
- break;
- }
- ptk_unpostmenu(debugwsid, windowmenuid);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_windowmenu */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_topologymenu(C(Pint) menuitem, C(Ppoint *) pos)
- PreANSI(Pint menuitem)
- PreANSI(Ppoint *pos)
- {
- Ppick_data pickrec;
- Ploc_data locrec;
- FILE *fileptr;
- char filename[80];
- Pint namelen;
-
- switch (menuitem)
- {
- case 1: /* type */
- ptk_setmenuposition(toptypemenuid, pos);
- ptk_postmenu(debugwsid, toptypemenuid);
- break;
-
- case 2: /* view */
- ptk_unpostmenu(debugwsid, topologymenuid);
- do_topologyview();
- curmenu = 0;
- break;
-
- case 3: /* tidy single */
- /* implementation dependent - pick and locator data records */
- /*
- #ifdef VMS
- pickrec.pets.pet_r1.aperature = 0.01;
- #endif
- */
- ptk_setwindowtraninputpri(topologywindow, 0, PPRI_HIGHER);
- ptk_tidytopology(debugwsid, topology, PTKESINGLE, PICKDEV, 1, &pickrec,
- LOCDEV, 1, &locrec);
- ptk_setwindowtraninputpri(topologywindow, 0, PPRI_LOWER);
- ptk_unpostmenu(debugwsid, topologymenuid);
- curmenu = 0;
- break;
-
- case 4: /* tidy group */
- /* implementation dependent - pick and locator data records */
- /*
- #ifdef VMS
- pickrec.pets.pet_r1.aperature = 0.01;
- #endif
- */
- ptk_setwindowtraninputpri(topologywindow, 0, PPRI_HIGHER);
- ptk_tidytopology(debugwsid, topology, PTKEGROUP, PICKDEV, 1, &pickrec,
- LOCDEV, 1, &locrec);
- ptk_setwindowtraninputpri(topologywindow, 0, PPRI_LOWER);
- ptk_unpostmenu(debugwsid, topologymenuid);
- curmenu = 0;
- break;
-
- case 5: /* store */
- ptk_readstring(debugwsid, "", "Input filename >", &echoarea,
- 80, filename, &namelen);
- if ((fileptr = fopen(filename, "w+")) != NULL)
- {
- rewind(fileptr);
- ptk_storetopologylayout(fileptr, topology);
- fclose(fileptr);
- ptk_printfterminal(terminalwindow, "topology layout stored in %s.\n",
- filename);
- }
- break;
-
- case 6: /* restore */
- ptk_readstring(debugwsid, "", "Input filename >", &echoarea,
- 80, filename, &namelen);
- if ((fileptr = fopen(filename, "r")) != NULL)
- {
- rewind(fileptr);
- ptk_restoretopologylayout(fileptr, topology);
- fclose(fileptr);
- ptk_printfterminal(terminalwindow,
- "topology layout restored from %s.\n", filename);
- }
- break;
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_topologymenu */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_contentmenu(C(Pint) menuitem)
- PreANSI(Pint menuitem)
- {
- Pint stid, elemptr;
-
- switch (menuitem)
- {
- case 1: /* set break */
- do_pickelem(&stid, &elemptr);
- if (elemptr != -1)
- do_setbreakpoint(stid, elemptr);
- ptk_unpostmenu(debugwsid, contentmenuid);
- break;
-
- case 2: /* set trace */
- do_pickelem(&stid, &elemptr);
- if (elemptr != -1)
- do_settracepoint(stid, elemptr);
- ptk_unpostmenu(debugwsid, contentmenuid);
- break;
-
- case 3: /* cancel break */
- do_pickelem(&stid, &elemptr);
- if (elemptr != -1)
- do_cancelbreakpoint(stid, elemptr);
- ptk_unpostmenu(debugwsid, contentmenuid);
- break;
-
- case 4: /* cancel trace */
- do_pickelem(&stid, &elemptr);
- if (elemptr != -1)
- do_canceltracepoint(stid, elemptr);
- ptk_unpostmenu(debugwsid, contentmenuid);
- break;
-
- case 5: /* scroll */
- ptk_unpostmenu(debugwsid, contentmenuid);
- do_scrollcontent();
- break;
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_contentmenu */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_structmenu(C(Pint) menuitem, C(Pint) windowid)
- PreANSI(Pint menuitem)
- PreANSI(Pint windowid)
- {
- Pint_list stlist;
-
- ptk_unpostmenu(debugwsid, structmenuid);
- switch (menuitem)
- {
- case 1: /* camera */
- camerainterface(windowid);
- break;
-
- case 2: /* reset */
- ptk_resetcamera(windowid);
- stlist.num_ints = 1;
- if (windowid == structwindow)
- stlist.ints = &debugrootstid;
- else
- stlist.ints = &elemcontent;
- ptk_setcameraworld(windowid, &stlist);
- break;
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_structmenu */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_terminalmenu(C(Pint) menuitem)
- PreANSI(Pint menuitem)
- {
- ptk_unpostmenu(debugwsid, terminalmenuid);
- switch (menuitem)
- {
- case 1: /* scroll */
- do_scrollterminal();
- break;
-
- case 2: /* clear */
- ptk_clearterminal(terminalwindow);
- break;
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_terminalmenu */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_toptypemenu(C(Pint) menuitem)
- PreANSI(Pint menuitem)
- {
- switch (menuitem)
- {
- case 1: /* box */
- ptk_settopologytype(topology, PTKEBOXTOPOLOGY);
- break;
-
- case 2: /* structure */
- ptk_settopologytype(topology, PTKESTRUCTTOPOLOGY);
- break;
-
- case 3: /* structure network */
- ptk_settopologytype(topology, PTKESTRUCTNETTOPOLOGY);
- break;
- }
- ptk_unpostmenu(debugwsid, toptypemenuid);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_toptypemenu */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_tslmenu(C(Pint) menuitem)
- PreANSI(Pint menuitem)
- {
- Pint ind, colour, style, type, styleind, font, totsize, i;
- Pedge_flag flag;
- Ptext_prec prec;
- Ptext_path path;
- Ptext_align align;
- Ppoint charup;
- Pfloat exp, spacing, size;
- Pmatrix3 global, local;
- Pint_list nameset;
- Pint pickid, hlhsrid, viewindex;
- Paspect attrid;
- Pasf asf;
- Plimit3 bbox;
-
- switch (menuitem)
- {
- case 1: /* line */
- ptk_inqtslline(&ind, &type, &size, &colour);
- ptk_printfterminal(terminalwindow, "line index = %d\n", ind);
- ptk_printfterminal(terminalwindow, "line type = %d\n", type);
- ptk_printfterminal(terminalwindow, "linewidth = %f\n", size);
- ptk_printfterminal(terminalwindow, "line colour = %d\n", colour);
- break;
-
- case 2: /* marker */
- ptk_inqtslmarker(&ind, &type, &size, &colour);
- ptk_printfterminal(terminalwindow, "marker index = %d\n", ind);
- ptk_printfterminal(terminalwindow, "marker type = %d\n", type);
- ptk_printfterminal(terminalwindow, "marker size = %f\n", size);
- ptk_printfterminal(terminalwindow, "marker colour = %d\n", colour);
- break;
-
- case 3: /* interior */
- ptk_inqtslinterior(&ind, &style, &styleind, &colour);
- ptk_printfterminal(terminalwindow, "interior index = %d\n", ind);
- ptk_printfterminal(terminalwindow, "interior style = %d\n", style);
- ptk_printfterminal(terminalwindow, "interior style index = %d\n", styleind);
- ptk_printfterminal(terminalwindow, "interior colour = %d\n", colour);
- break;
-
- case 4: /* edge */
- ptk_inqtsledge(&ind, &flag, &type, &size, &colour);
- ptk_printfterminal(terminalwindow, "edge index = %d\n", ind);
- ptk_printfterminal(terminalwindow, "edge flag = %d\n", style);
- ptk_printfterminal(terminalwindow, "edge type = %d\n", type);
- ptk_printfterminal(terminalwindow, "edgewidth = %f\n", size);
- ptk_printfterminal(terminalwindow, "edge colour = %d\n", colour);
- break;
-
- case 5: /* text */
- ptk_inqtsltext(&ind, &font, &prec, &path, &align, &colour);
- ptk_printfterminal(terminalwindow, "text index = %d\n", ind);
- ptk_printfterminal(terminalwindow, "text font = %d\n", font);
- ptk_printfterminal(terminalwindow, "text precision = %d\n", prec);
- ptk_printfterminal(terminalwindow, "text path = %d\n", path);
- ptk_printfterminal(terminalwindow, "text alignment, hor = %d\n", align.hor);
- ptk_printfterminal(terminalwindow, "text alignment, ver = %d\n", align.vert);
- ptk_printfterminal(terminalwindow, "text colour = %d\n", colour);
- break;
-
- case 6: /* annotext */
- ptk_inqtslannotext(&style, &size, &charup, &align, &path);
- ptk_printfterminal(terminalwindow, "anno text style = %d\n", style);
- ptk_printfterminal(terminalwindow, "anno text height= %f\n", size);
- ptk_printfterminal(terminalwindow, "anno text char up = %f %f\n",
- charup.x, charup.y);
- ptk_printfterminal(terminalwindow, "anno text alignment, hor = %d\n", align.hor);
- ptk_printfterminal(terminalwindow, "anno text alignment, ver = %d\n", align.vert);
- ptk_printfterminal(terminalwindow, "anno text path = %d\n", path);
- break;
-
- case 7: /* char */
- ptk_inqtslchar(&exp, &spacing, &size, &charup);
- ptk_printfterminal(terminalwindow, "char expansion = %f\n", exp);
- ptk_printfterminal(terminalwindow, "char spacing = %f\n", spacing);
- ptk_printfterminal(terminalwindow, "char height = %f\n", size);
- ptk_printfterminal(terminalwindow, "char up = %f %f\n",
- charup.x, charup.y);
- break;
-
- case 8: /* ctm */
- ptk_inqtslctm(global, local);
- ptk_printfterminal(terminalwindow, "global transformation:\n");
- for (i = 0; i <= 3; i++)
- ptk_printfterminal(terminalwindow, "%f %f %f %f\n", global[i][0],
- global[i][1], global[i][2], global[i][3]);
- ptk_printfterminal(terminalwindow, "local transformation:\n");
- for (i = 0; i <= 3; i++)
- ptk_printfterminal(terminalwindow, "%f %f %f %f\n", local[i][0],
- local[i][1], local[i][2], local[i][3]);
- break;
-
- case 9: /* nameset */
- ptk_inqtslnameset(0, &nameset, &totsize);
- nameset.num_ints = totsize;
- nameset.ints = (Pint *)calloc(totsize, sizeof(Pint));
- ptk_inqtslnameset(totsize, &nameset, &totsize);
- ptk_printfterminal(terminalwindow, "nameset, number = %d\n", nameset.num_ints);
- ptk_printfterminal(terminalwindow, "nameset, integers = ");
- for (i = 0; i < nameset.num_ints; i++)
- ptk_printfterminal(terminalwindow, " %d ", nameset.ints[i]);
- ptk_printfterminal(terminalwindow, "\n");
- free(nameset.ints);
- break;
-
- case 10: /* ids */
- ptk_inqtslids(&pickid, &hlhsrid, &viewindex);
- ptk_printfterminal(terminalwindow, "pick identifier = %d\n", pickid);
- ptk_printfterminal(terminalwindow, "HLHSR identifier = %d\n", hlhsrid);
- ptk_printfterminal(terminalwindow, "view index = %d\n", viewindex);
- break;
-
- case 11: /* asf */
- attrid = ptk_readint(debugwsid, 1,
- "Input number of attribute type>", &echoarea);
- ptk_inqtslattrasf(attrid, &asf);
- ptk_printfterminal(terminalwindow, "asf = %d\n", asf);
- break;
-
- case 12: /* bbox */
- ptk_inqboundingbox(&bbox);
- ptk_printfterminal(terminalwindow, "bounding box:\n");
- ptk_printfterminal(terminalwindow, "xmin = %f, xmax = %f\n", bbox.x_min, bbox.x_max);
- ptk_printfterminal(terminalwindow, "ymin = %f, ymax = %f\n", bbox.y_min, bbox.y_max);
- ptk_printfterminal(terminalwindow, "zmin = %f, zmax = %f\n", bbox.z_min, bbox.z_max);
- break;
- }
- ptk_unpostmenu(debugwsid, tslmenuid);
- ptk_unpostmenu(debugwsid, tsl2menuid);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- } /* do_tslmenu */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_pickinput(C(Ppick_path *) inpick)
- PreANSI(Ppick_path *inpick)
- {
- Pint stid, i, err;
-
- /* topology node */
- if (inpick->path_list[1].struct_id == topologystid)
- {
- ptkewindowstate state;
-
- ptk_inqwindowstate(contentwindow, &state, &err);
- if (state == PTKEWINDOWOPEN)
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_NIVE);
- stid = inpick->path_list[1].pick_id;
- ptk_settopologyhighlightnode(topology, stid);
- /* update structure content */
- pempty_struct(structcontent);
- ptk_openstruct(structcontent);
- padd_names_set(&contentset);
- ptk_structcontent(debugwsid, stid, 0, PTKSTCTLIMIT, 0, 1, &err);
- currentcontent = stid;
- premove_names_set(&contentset);
- drawbreakpts(stid);
- drawtracepts(stid);
- ptk_closestruct();
- contentlowlim = 0;
- contentuplim = PTKSTCTLIMIT;
- ptk_posttowindow(contentwindow, structcontent);
- ptk_setcontentviewrange(contentwindow, 0, 10);
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- else /* change structure content window */
- if (inpick->path_list[1].struct_id == structcontent)
- {
- Pint elemid, err;
- Pelem_type eltype;
-
- elemid = inpick->path_list[1].pick_id;
- ptk_openstruct(currentcontent);
- pset_elem_ptr(elemid);
- ptk_inqcurelemtype(&err, &eltype);
- if (eltype == PELEM_EXEC_STRUCT)
- do_examine(currentcontent, elemid);
- else
- do_examine(getcopystid(currentcontent), elemid);
- ptk_closestruct();
- }
- } /* do_pickinput */
-
- /*--------------------------------------------------------------------------*/
-
- static void debugmainloop()
- {
- ptkboolean debugquit, trigger, doubletrigger;
- Pint ws, devnum;
- Pin_class class, dtclass;
- Ppoint initpt, position;
- Pint initview, view_index;
- ptksgeneralinput geninput;
- ptksmenuoutput menuoutput;
- ptkswindowoutput windowoutput;
- Ploc_data locrec;
- Plimit echo;
- Plimit3 echo3;
- Ppick_path initpath;
- Ppick_data pickdatarec;
- Pin_status status;
- Ppick_path inputpick;
- Pint err, i, stid;
- Ppick_path_elem pathel[10];
- Pint themenu;
-
- pflush_events(debugwsid, PIN_LOC, LOCDEV);
- pflush_events(debugwsid, PIN_PICK, PICKDEV);
- debugquit = FALSE;
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- initview = 0;
- initpt = ptk_point(0.5, 0.5);
- echo = ptk_limit(0.0, devx, 0.0, devy);
- /* Implementation dependent - locator device data record */
- #ifdef HP
- locrec.pets.pet_r1.loc_colr_ind = 1;
- #endif
- pinit_loc(debugwsid, LOCDEV, initview, &initpt, 1, &echo, &locrec);
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- echo3 = ptk_limit3(0.0, devx, 0.0, devy, 0.0, devz);
- pset_pick_mode(debugwsid, PICKDEV, POP_REQ, PSWITCH_ECHO);
- initpath.depth = 0;
- /* Implementation dependent - pick data record */
- #ifdef VMS
- pickdatarec.pets.pet_r1.aperature = 0.01;
- #endif
- #ifdef HP
- pickdatarec.pets.pet_r1.highl_colr_ind = 0;
- pickdatarec.pets.pet_r1.x_dim = 0.005;
- pickdatarec.pets.pet_r1.y_dim = 0.005;
- pickdatarec.pets.pet_r1.z_dim = 2.0;
- #endif
- /* Implementation dependent code because of differences in
- ** valid initial status.
- */
- #ifdef SUN
- pinit_pick3(debugwsid, PICKDEV, PIN_STATUS_NONE, &initpath, 1, &echo3,
- &pickdatarec, PORDER_TOP_FIRST);
- #endif
- #ifdef HP
- pinit_pick3(debugwsid, PICKDEV, PIN_STATUS_NO_IN, &initpath, 1, &echo3,
- &pickdatarec, PORDER_TOP_FIRST);
- #endif
- #ifdef PEXSI
- pinit_pick3(debugwsid, PICKDEV, PIN_STATUS_NO_IN, &initpath, 1, &echo3,
- &pickdatarec, PORDER_TOP_FIRST);
- #endif
- pset_pick_mode(debugwsid, PICKDEV, POP_EVENT, PSWITCH_ECHO);
- inputpick.path_list = pathel;
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- do
- {
- /* update state use quick update */
- pset_disp_upd_st(debugwsid, PDEFER_WAIT, PMODE_UQUM);
- trigger = FALSE;
- doubletrigger = FALSE;
- status = PIN_STATUS_NONE;
- /* get locator and pick events */
- pawait_event(0.0, &ws, &class, &devnum);
- if ((ws == debugwsid) && ((class == PIN_LOC) || (class == PIN_PICK)))
- {
- trigger = TRUE;
- if (class == PIN_LOC)
- {
- pget_loc(&view_index, &position);
- pawait_event(0.0, &ws, &dtclass, &devnum);
- if (dtclass == PIN_PICK)
- {
- pget_pick(10, &status, &inputpick);
- doubletrigger = TRUE;
- }
- }
- else
- {
- pget_pick(10, &status, &inputpick);
- pawait_event(0.0, &ws, &dtclass, &devnum);
- if (dtclass == PIN_LOC)
- {
- pget_loc(&view_index, &position);
- doubletrigger = TRUE;
- }
- }
- }
- if (trigger)
- {
- if ((!doubletrigger) && (class == PIN_PICK))
- do_pickinput(&inputpick);
- else
- {
- geninput.inputclass = PIN_LOC;
- geninput.ptkugeninput.locpoint = position;
- if (ptk_scanmenus(debugwsid, &geninput, &menuoutput))
- {
- pset_loc_mode(debugwsid, LOCDEV, POP_REQ, PSWITCH_ECHO);
- pset_pick_mode(debugwsid, PICKDEV, POP_REQ, PSWITCH_ECHO);
- if (menuoutput.menuid == debugmenuid)
- {
- if (menuoutput.itemnum == 10)
- debugquit = TRUE;
- else
- do_debugmenu(menuoutput.itemnum, &position);
- }
- else
- if (menuoutput.menuid == windowmenuid)
- {
- do_windowmenu(menuoutput.itemnum, &windowoutput);
- curmenu = 0;
- }
- else
- if (menuoutput.menuid == topologymenuid)
- {
- do_topologymenu(menuoutput.itemnum, &position);
- }
- else
- if (menuoutput.menuid == contentmenuid)
- {
- do_contentmenu(menuoutput.itemnum);
- curmenu = 0;
- }
- else
- if (menuoutput.menuid == structmenuid)
- {
- do_structmenu(menuoutput.itemnum, windowoutput.windowid);
- }
- else
- if (menuoutput.menuid == terminalmenuid)
- {
- do_terminalmenu(menuoutput.itemnum);
- curmenu = 0;
- }
- else
- if (menuoutput.menuid == toptypemenuid)
- {
- do_toptypemenu(menuoutput.itemnum);
- }
- else
- if (menuoutput.menuid == tslmenuid)
- {
- do_tslmenu(menuoutput.itemnum);
- }
- if (menuoutput.menuid == tsl2menuid)
- {
- do_tslmenu(menuoutput.itemnum + 6);
- }
- pset_loc_mode(debugwsid, LOCDEV, POP_EVENT, PSWITCH_ECHO);
- pset_pick_mode(debugwsid, PICKDEV, POP_EVENT, PSWITCH_ECHO);
- pset_pick_filter(debugwsid, PICKDEV, &pickfilt);
- }
- else
- if (ptk_scanwindows(debugwsid, &geninput, &windowoutput))
- {
- Pint err;
-
- if (doubletrigger && (status == PIN_STATUS_OK) &&
- ((windowoutput.windowid == topologywindow) ||
- (windowoutput.windowid == contentwindow)))
- do_pickinput(&inputpick);
- else
- if ((windowoutput.windowarea == PTKEWINDOWICON) ||
- (windowoutput.windowarea == PTKEWINDOWBANNER))
- {
- ptk_unpostallmenu(debugwsid);
- if (windowoutput.windowarea == PTKEWINDOWICON)
- ptk_createtextmenuitem(windowmenuid, "open", 1, PEDIT_REPLACE,
- &err);
- else
- ptk_createtextmenuitem(windowmenuid, "close", 1, PEDIT_REPLACE,
- &err);
- ptk_setmenuposition(windowmenuid, &position);
- if ((curmenu != windowmenuid) ||
- (curwindow != windowoutput.windowid))
- {
- ptk_postmenu(debugwsid, windowmenuid);
- curmenu = windowmenuid;
- curwindow = windowoutput.windowid;
- }
- else
- {
- curmenu = 0;
- curwindow = 0;
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- else
- {
- if (windowoutput.windowid == topologywindow)
- themenu = topologymenuid;
- else
- if (windowoutput.windowid == contentwindow)
- themenu = contentmenuid;
- else
- if ((windowoutput.windowid == structwindow) ||
- (windowoutput.windowid == elementwindow))
- themenu = structmenuid;
- else
- if (windowoutput.windowid == terminalwindow)
- themenu = terminalmenuid;
- ptk_unpostallmenu(debugwsid);
- if ((curmenu != themenu) ||
- (curwindow != windowoutput.windowid))
- {
- ptk_setmenuposition(themenu, &position);
- ptk_postmenu(debugwsid, themenu);
- curmenu = themenu;
- curwindow = windowoutput.windowid;
- }
- else
- {
- curmenu = 0;
- curwindow = 0;
- }
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- }
- else
- {
- curwindow = 0;
- ptk_unpostallmenu(debugwsid);
- if (curmenu != debugmenuid)
- {
- ptk_setmenuposition(debugmenuid, &position);
- ptk_postmenu(debugwsid, debugmenuid);
- curmenu = debugmenuid;
- }
- else
- curmenu = 0;
- ptk_redrawallstructs(debugwsid, PFLAG_ALWAYS);
- }
- }
- }
- /* Implementation dependent - for some reason PEX-SI requires
- ** the pick device mode to be re-set after each trigger/event.
- */
- #ifdef PEXSI
- pset_pick_mode(debugwsid, PICKDEV, POP_EVENT, PSWITCH_ECHO);
- #endif
- } while (!debugquit);
- pflush_events(debugwsid, PIN_LOC, LOCDEV);
- pflush_events(debugwsid, PIN_PICK, PICKDEV);
- } /* debugmainloop */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_debugger(C(Pint) wsid, C(Pint) stid)
- PreANSI(Pint wsid)
- PreANSI(Pint stid)
- /*
- ** \parambegin
- ** \param{Pint}{wsid}{workstation identifier}{IN}
- ** \param{Pint}{stid}{structure identifier}{IN}
- ** \paramend
- ** \blurb{This function starts the PHIGS debugger on workstation
- ** \pardesc{wsid}, and makes structure \pardesc{stid} the root of the
- ** structure network to be debugged. This function requires hashtables
- ** "structureid", "label", "name", "viewindex", "topologyid", "menuid",
- ** "windowid".}
- */
- {
- Ppoint pos, size;
- char ststr[20], str[20];
- Pint lenstr, err, stcom, i, totsize;
- Pint_list pmenus, pwindows;
- Pposted_struct_list structs;
- Pdefer_mode defmode;
- Pmod_mode modmode;
- Pdisp_surf_empty dspsurf;
- Pvisual_st visualrep;
- Pcolr_rep backrep;
- ptksexeclist *ptr, *temp;
-
- if (!ptk_structexists(stid))
- {
- fprintf(stderr, "Debugger: the given structure does not exist.\n");
- return;
- }
-
- /* inquire and set display update state */
- pinq_disp_upd_st(wsid, &err, &defmode, &modmode, &dspsurf, &visualrep);
- pset_disp_upd_st(wsid, PDEFER_WAIT, PMODE_NIVE);
-
- /* inquire and set background colour */
- pinq_colr_rep(wsid, 0, PINQ_SET, &err, &backrep);
- ptk_setbackgroundcolourind(wsid, backgroundcolourind);
-
- /* inquire all posted menus and windows */
- ptk_inqpostedmenus(wsid, 0, &pmenus, &totsize, &err);
- pmenus.ints = (Pint *)calloc(totsize, sizeof(Pint));
- ptk_inqpostedmenus(wsid, totsize, &pmenus, &totsize, &err);
- pmenus.num_ints = totsize;
- ptk_inqpostedwindows(wsid, 0, &pwindows, &totsize, &err);
- pwindows.ints = (Pint *)calloc(totsize, sizeof(Pint));
- ptk_inqpostedwindows(wsid, totsize, &pwindows, &totsize, &err);
- pwindows.num_ints = totsize;
- /* clear menus and windows */
- for (i = 0; i < pmenus.num_ints; i++)
- ptk_unpostmenu(wsid, pmenus.ints[i]);
- for (i = 0; i < pwindows.num_ints; i++)
- ptk_unpostwindow(wsid, pwindows.ints[i]);
-
- /* inquire all other posted structure */
- pinq_posted_structs(wsid, 0, 0, &err, &structs, &totsize);
- structs.postings = (Pposted_struct *)calloc(totsize, sizeof(Pposted_struct));
- pinq_posted_structs(wsid, totsize, 0, &err, &structs, &totsize);
- structs.num_postings = totsize;
- /* clear all posted structures */
- punpost_all_structs(wsid);
-
- /* stack TSL */
- ptk_stacktsl();
-
- /* clear workstation */
-
- debugwsid = wsid;
- debugrootstid = stid;
- /* set up windows */
- pos = ptk_point(0.25, 0.25);
- size = ptk_point(0.45, 0.45);
-
- structwindow = ptk_stringtoint("windowid", "ptk$dbgstructwindow");
- topologywindow = ptk_stringtoint("windowid", "ptk$dbgtopologywindow");
- contentwindow = ptk_stringtoint("windowid", "ptk$dbgcontentwindow");
- terminalwindow = ptk_stringtoint("windowid", "ptk$dbgterminalwindow");
- elementwindow = ptk_stringtoint("windowid", "ptk$dbgelementwindow");
- ptk_createwindow(wsid, structwindow, &size, &pos, "structure");
- ptk_setwindowattrs(structwindow, windowtextfont, bannertextcolourind,
- bannercolourind, windowcolourind, bannercolourind,
- tlcolourind, brcolourind);
- pos = ptk_point(0.25, 0.75);
- ptk_createwindow(wsid, topologywindow, &size, &pos, "topology");
- ptk_setwindowattrs(topologywindow, windowtextfont, bannertextcolourind,
- bannercolourind, windowcolourind, bannercolourind,
- tlcolourind, brcolourind);
- pos = ptk_point(0.75, 0.75);
- ptk_createwindow(wsid, contentwindow, &size, &pos, "content");
- ptk_setwindowattrs(contentwindow, windowtextfont, bannertextcolourind,
- bannercolourind, windowcolourind, bannercolourind,
- tlcolourind, brcolourind);
- pos = ptk_point(0.75, 0.25);
- ptk_createwindow(wsid, terminalwindow, &size, &pos, "terminal");
- ptk_setwindowattrs(terminalwindow, windowtextfont, bannertextcolourind,
- bannercolourind, windowcolourind, bannercolourind,
- tlcolourind, brcolourind);
- pos = ptk_point(0.5, 0.5);
- ptk_createwindow(wsid, elementwindow, &size, &pos, "element");
- ptk_setwindowattrs(elementwindow, windowtextfont, bannertextcolourind,
- bannercolourind, windowcolourind, bannercolourind,
- tlcolourind, brcolourind);
- ptk_setwindowtype(topologywindow, PTKETOPOLOGYWINDOW);
- ptk_setwindowtype(contentwindow, PTKECONTENTWINDOW);
- ptk_setwindowtype(terminalwindow, PTKETERMINALWINDOW);
- ptk_postwindow(structwindow);
- ptk_postwindow(terminalwindow);
- ptk_postwindow(topologywindow);
- ptk_postwindow(contentwindow);
-
- /* set up menus */
- makemenus();
-
- ptk_inqmaxdevicecoords3(debugwsid, &devx, &devy, &devz);
- echoarea = ptk_limit(0.0, devx * 0.5, 0.0, devy * 0.05);
- setupdebugger();
-
- /* make a copy of the structure network so that
- ** deposit doesn't affect the original.
- */
- copynetwork(stid);
-
- /* set up debugger traversal */
- initialisedebugger(stid);
-
- ptk_settslstart(getcopystid(stid), 0);
- ptk_tsltraversenext();
-
- /* interaction loop */
- debugmainloop();
-
- pset_disp_upd_st(wsid, PDEFER_WAIT, PMODE_NIVE);
-
- /* tidy up before exit */
- ptk_delwindow(structwindow);
- ptk_delwindow(topologywindow);
- ptk_delwindow(contentwindow);
- ptk_delwindow(terminalwindow);
- ptk_delwindow(elementwindow);
-
- /* reset debugger variables */
- elemposted = FALSE;
- debugstack = NULL;
- stpoints = NULL;
- dbgcount = 0;
- debugstackdepth = 0;
- curmenu = 0;
- curwindow = 0;
- topview = ptk_limit(0.0, 1.0, 0.0, 1.0);
-
- ptk_delstring("windowid", "ptk$dbgstructwindow");
- ptk_delstring("windowid", "ptk$dbgtopologywindow");
- ptk_delstring("windowid", "ptk$dbgcontentwindow");
- ptk_delstring("windowid", "ptk$dbgterminalwindow");
- ptk_delstring("windowid", "ptk$dbgelementwindow");
-
- ptk_delmenu(debugmenuid);
- ptk_delmenu(windowmenuid);
- ptk_delmenu(topologymenuid);
- ptk_delmenu(contentmenuid);
- ptk_delmenu(structmenuid);
- ptk_delmenu(terminalmenuid);
- ptk_delmenu(toptypemenuid);
- ptk_delmenu(tslmenuid);
- ptk_delmenu(tsl2menuid);
-
- ptk_delstring("menuid", "ptk$debugmenu");
- ptk_delstring("menuid", "ptk$windowmenu");
- ptk_delstring("menuid", "ptk$topologymenu");
- ptk_delstring("menuid", "ptk$contentmenu");
- ptk_delstring("menuid", "ptk$structmenu");
- ptk_delstring("menuid", "ptk$terminalmenu");
- ptk_delstring("menuid", "ptk$toptypemenu");
- ptk_delstring("menuid", "ptk$tslmenu");
- ptk_delstring("menuid", "ptk$tsl2menu");
-
- ptk_delmenu(rot3d1);
- ptk_delmenu(rot3d2);
- ptk_delmenu(rot2d1);
- ptk_delmenu(rot2d2);
- ptk_delmenu(rot1d);
-
- ptk_delstring("menuid", "ptk$rotator3d1");
- ptk_delstring("menuid", "ptk$rotator3d2");
- ptk_delstring("menuid", "ptk$rotator2d1");
- ptk_delstring("menuid", "ptk$rotator2d2");
- ptk_delstring("menuid", "ptk$rotator1d");
-
- ptk_deltopology(topology);
-
- deletecopynetwork();
- clearstructid();
- pdel_struct(elemcontent);
- pdel_struct(elembuffer);
- pdel_struct(structcontent);
-
- /* unstack TSL */
- ptk_tsltraversetoend();
- ptk_unstacktsl();
-
- /* free break/trace points */
- ptr = stpoints;
- while (ptr != NULL)
- {
- temp = ptr->next;
- free(ptr->bkpts);
- free(ptr->tcpts);
- free(ptr);
- ptr = temp;
- }
-
- /* repost all menus, windows and other structs */
- for (i = 0; i < structs.num_postings; i++)
- ppost_struct(wsid, structs.postings[i].id, structs.postings[i].disp_pri);
- for (i = 0; i < pwindows.num_ints; i++)
- ptk_postwindow(pwindows.ints[i]);
- for (i = 0; i < pmenus.num_ints; i++)
- ptk_postmenu(wsid, pmenus.ints[i]);
- free(structs.postings);
- free(pmenus.ints);
- free(pwindows.ints);
-
- /* background colour */
- pset_colr_rep(wsid, 0, &backrep);
-
- ptk_redrawallstructs(wsid, PFLAG_ALWAYS);
-
- /* restore display update state */
- pset_disp_upd_st(wsid, defmode, modmode);
- } /* ptk_debugger */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setdebuggerattrs(C(Pint) menufont,
- C(Pint) windowfont, C(Pint) menucol, C(Pint) menutextcol,
- C(Pint) windowcol, C(Pint) bannercol, C(Pint) bannertextcol,
- C(Pint) tlcol, C(Pint) brcol, C(Pint) arrowcol, C(Pint) arrowedgecol)
- PreANSI(Pint menufont)
- PreANSI(Pint windowfont)
- PreANSI(Pint menucol)
- PreANSI(Pint menutextcol)
- PreANSI(Pint windowcol)
- PreANSI(Pint bannercol)
- PreANSI(Pint bannertextcol)
- PreANSI(Pint tlcol)
- PreANSI(Pint brcol)
- PreANSI(Pint arrowcol)
- PreANSI(Pint arrowedgecol)
- /*
- ** \parambegin
- ** \param{Pint}{menufont}{menu text font}{IN}
- ** \param{Pint}{windowfont}{window text font}{IN}
- ** \param{Pint}{menucol}{menu colour index}{IN}
- ** \param{Pint}{menutextcol}{menu text colour index}{IN}
- ** \param{Pint}{windowcol}{window interior colour index}{IN}
- ** \param{Pint}{bannercol}{window banner colour index}{IN}
- ** \param{Pint}{bannertextcol}{window banner text colour index}{IN}
- ** \param{Pint}{tlcol}{top-left colour index}{IN}
- ** \param{Pint}{brcol}{bottom-right colour index}{IN}
- ** \param{Pint}{arrowcol}{arrow colour index}{IN}
- ** \param{Pint}{arrowedgecol}{arrow edge colour index}{IN}
- ** \paramend
- ** \blurb{This function enables an application to set
- ** the fonts and colours of menus and windows in the PHIGS debugger.}
- */
- {
- menutextfont = menufont;
- windowtextfont = windowfont;
- menucolourind = menucol;
- windowcolourind = windowcol;
- menutextcolourind = menutextcol;
- bannercolourind = bannercol;
- bannertextcolourind = bannertextcol;
- tlcolourind = tlcol;
- brcolourind = brcol;
- arrowcolourind = arrowcol;
- arrowedgecolourind = arrowedgecol;
- } /* ptk_setdebuggerattrs */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqdebuggerattrs(C(Pint *) menufont, C(Pint *) windowfont,
- C(Pint *) menucol, C(Pint *) menutextcol, C(Pint *) windowcol,
- C(Pint *) bannercol, C(Pint *) bannertextcol, C(Pint *) tlcol,
- C(Pint *) brcol, C(Pint *) arrowcol, C(Pint *) arrowedgecol)
- PreANSI(Pint *menufont)
- PreANSI(Pint *windowfont)
- PreANSI(Pint *menucol)
- PreANSI(Pint *menutextcol)
- PreANSI(Pint *windowcol)
- PreANSI(Pint *bannercol)
- PreANSI(Pint *bannertextcol)
- PreANSI(Pint *tlcol)
- PreANSI(Pint *brcol)
- PreANSI(Pint *arrowcol)
- PreANSI(Pint *arrowedgecol)
- /*
- ** \parambegin
- ** \param{Pint *}{menufont}{menu text font}{IN}
- ** \param{Pint *}{windowfont}{window text font}{IN}
- ** \param{Pint *}{menucol}{menu colour index}{IN}
- ** \param{Pint *}{menutextcol}{menu text colour index}{IN}
- ** \param{Pint *}{windowcol}{window interior colour index}{IN}
- ** \param{Pint *}{bannercol}{window banner colour index}{IN}
- ** \param{Pint *}{bannertextcol}{window banner text colour index}{IN}
- ** \param{Pint *}{tlcol}{top-left colour index}{IN}
- ** \param{Pint *}{brcol}{bottom-right colour index}{IN}
- ** \param{Pint *}{arrowcol}{arrow colour index}{IN}
- ** \param{Pint *}{arrowedgecol}{arrow edge colour index}{IN}
- ** \paramend
- ** \blurb{This function may be used to obtain the text font and
- ** colour attribute values of menus and windows used in the PHIGS debugger.}
- */
- {
- *menufont = menutextfont;
- *windowfont = windowtextfont;
- *menucol = menucolourind;
- *windowcol = windowcolourind;
- *menutextcol = menutextcolourind;
- *bannercol = bannercolourind;
- *bannertextcol = bannertextcolourind;
- *tlcol = tlcolourind;
- *brcol = brcolourind;
- *arrowcol = arrowcolourind;
- *arrowedgecol = arrowedgecolourind;
- } /* ptk_inqdebuggerattrs */
-
- /*--------------------------------------------------------------------------*/
-
- /* end of dbug.c */
-